/* -*- Mode: c; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/*
  RefObject (http://code.google.com/p/refobject/)
  Copyright (C) 2010-2011 MIURA Shirow (sharow)
*/

#ifndef INCLUDED_REFALLOCATOR_H
#define INCLUDED_REFALLOCATOR_H

#include <stddef.h>

#include <RefObject/RefObject.h>

typedef void *(*RefAllocatorStdCMalloc)(size_t aSize);
typedef void (*RefAllocatorStdCFree)(void *aPtr);
typedef void *(*RefAllocatorUserAlloc)(void *aUserData, unsigned int aSize);
typedef void (*RefAllocatorUserFree)(void *aUserData, void *aPtr);

RefTypeObject **RefAllocator_GetTypeObject(void);
RefObject *RefAllocator_CreateFromStdCMallocFree(RefAllocatorStdCMalloc aStdCMalloc,
                                                 RefAllocatorStdCFree aStdCFree);
int RefAllocator_IsValid(RefObject *aRefObject);
void *RefAllocator_Alloc(RefObject *aRefObject, unsigned int aSize);
void RefAllocator_Free(RefObject *aRefObject, void *aPtr);

RefObject *RefAllocatorForModule_CreateFromStdCMallocFree(RefAllocatorStdCMalloc aStdCMalloc,
                                                          RefAllocatorStdCFree aStdCFree);

#endif
